package com.jt.provider.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 基于此controller演示配置中心的作用.
 * 在这个controller中我们会基于日志对象
 * 进行日志输出测试.
 */
@RefreshScope
@RestController
public class ProviderLogController {
    private static Logger log= LoggerFactory.getLogger(ProviderLogController.class);

    @Value("${logging.level.com.jt:error}")
    private String logLevel;

    @GetMapping("/provider/log/doLog01")
    public String doLog01(){
        System.out.println("==doLog01==");
        log.trace("====trace====");
        log.debug("====debug====");
        log.info("====info====");
        log.warn("====warn====");
        log.error("====error====");
        return "log config test";
    }

    @GetMapping("/provider/log/doLog02")
    public String doLog02(){
        log.info("log level is {}",logLevel);//内部感知
        return "log level is  "+logLevel;//外部感知
    }




}
